package com.calvin.study.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;


@Configuration
public class SessionConfig  {
	
	@Bean
	public CookieSerializer cookieSerializer() {
		DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
		//自定义session作用域
		cookieSerializer.setDomainName("calvin.com");
		//自定义session名称
		cookieSerializer.setCookieName("CALVIN-SESSION");
		return cookieSerializer;
	}
	
	//自定义session的json序列化方式
	@Bean
	public RedisSerializer<Object> springSessionDefaultRedisSerializer(){
		return new GenericJackson2JsonRedisSerializer();
	}
	
//	private ClassLoader loader;
//
//	@Override
//	public void setBeanClassLoader(ClassLoader classLoader) {
//		this.loader = classLoader;
//	}

}
